#!/usr/bin/python3
# -*- coding: utf-8 -*-
# @Time : 2021/9/12 15:32
# @Author : lenovo
# @Email : 26541796406@qq.com
# @File : read_method.py
# @Project : crm
"""项目工具类函数"""
import xlrd
import csv
def read_data_from_txt(file):
    """从txt文件读取数据"""
    with open(file,encoding='utf-8') as f:
        datas = f.read()
    datas = datas.splitlines()[1:]
    ret = []
    for data in datas:
        ret.append(data.split(','))
    return ret

def read_data_from_excel(file):
    """从excel文件读取数据"""
    data = xlrd.open_workbook(file)
    table = data.sheet_by_name("Sheet1")
    datas = []
    for index in range(1,table.nrows):
        line = table.row_values(index)
        line[1] = str(int(line[1]))
        datas.append(line)
    return datas
def read_data_from_csv(file):
    """从csv文件读取数据"""
    f = open(file,'r',encoding='utf-8-sig')
    data = csv.reader(f)
    datas = []
    for user in data:
        datas.append(user)
    return datas